/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q0100.java
 * @Author : WangRuoyu
 * @Date 2022/12/27 17:17
 */

package leetcode;

import util.TreeNode;

public class Q0100 {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) return true;
        if (p != null && q != null) {
            return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
        }
        return false;
    }

    public static void main(String[] args) {
        Q0100 sl = new Q0100();
        TreeNode p = new TreeNode(1, new TreeNode(2, new TreeNode(4), null), new TreeNode(3));
        TreeNode q = new TreeNode(1, new TreeNode(2, new TreeNode(4), null), new TreeNode(3));
        System.out.println(sl.isSameTree(p, q));
    }
}
